#include <iostream>
#include <fstream>

#include "Instance.h"
#include "State.h"
#include "Solver.h"

using namespace std;

inline void printUsage() {
  cout << "x36par - mbg" << endl;
  cout << "Usage: main <filename>" << endl;
}

int main(int argc, char* argv[]) {
  if (argc < 2) {
    printUsage();
    return ( 1 );
  }
  fstream kFile;
  kFile.open(argv[1]);
  if (!kFile || kFile.eof()) {
    cerr << "File not found or empty" << endl;
    return ( 1 );
  }

  try {
    Instance kInstance;
    kFile >> kInstance;
  
    Solver kSolver(&kInstance);
    cout << kSolver.solve();

    cout << "RESULT\t" << kSolver.getElapsed() << " seconds" << endl
       << "\t" << kSolver.getCount() << " states" << endl;

    if (kSolver.getElapsed()) 
    cout  << "\t" << kSolver.getCount()/kSolver.getElapsed() << " states/second" << endl;

  } catch (const char* e)  {
    cerr << e << endl;
    return ( 1 );
  }

#ifdef DEBUG
  cout << "Jste strasni kokoti!" << endl;
#endif
  return ( 0 );
}
// vim: ts=2 fdm=marker syntax=cpp expandtab sw=2
